package model;

import java.util.ArrayList;
import java.util.Collection;

import persistency.writer.Writable;

/**
 * 
 * @author Wim The Student class is an abstract model class that stores
 *         information about a Student like studentNumber, name, course history
 *         and registrations.
 * 
 */
public abstract class Student implements Writable{

	private String studentNumber;
	private String name;
	private Collection<CourseHistory> courseHistories = new ArrayList<CourseHistory>();
	private Collection<Registration> registrations = new ArrayList<Registration>();
	
	/** Constructs a new student object */
	public Student() {
	}
	
	/**
	 * Constructor to instantiate a Student with a studentNumber and name.
	 * 
	 * @param studentNumber
	 *            The Student number
	 * @param name
	 *            The student name
	 */
	public Student(String studentNumber, String name) {
		this.name = name;
		this.studentNumber = studentNumber;
	}

	/**
	 * 
	 * @return The number of the Student
	 */
	public String getStudentNumber() {
		return studentNumber;
	}

	/**
	 * Sets the number of the Student to the number of the argument.
	 * 
	 * @param studentNumber
	 *            A String value indicating the number to be assigned to the
	 *            Student
	 */
	public void setStudentNumber(String studentNumber) {
		this.studentNumber = studentNumber;
	}

	/**
	 * 
	 * @return The name of the student
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the name of the Student to the name of the argument.
	 * 
	 * @param name
	 *            A String value indicating the name to be assigned to the
	 *            Student
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 
	 * @return A collection the Students courseHistories.
	 */
	public Collection<CourseHistory> getCourseHistories() {
		return courseHistories;
	}

	/**
	 * Set the students course history to the collection passed in the argument.
	 * 
	 * @param courseHistories
	 *            A collection of CourseHistory indicating the students course
	 *            histories.
	 */
	public void setCourseHistories(Collection<CourseHistory> courseHistories) {
		this.courseHistories = courseHistories;
	}

	/**
	 * 
	 * @return A collection of the Students registrations.
	 */
	public Collection<Registration> getRegistrations() {
		return registrations;
	}

	/**
	 * Sets the registrations of the Student
	 * 
	 * @param registrations
	 *            A collection of registrations indicating the students
	 *            registrations.
	 */
	public void setRegistrations(Collection<Registration> registrations) {
		this.registrations = registrations;
	}
	
	@Override
	public String toDataString(){
		return studentNumber + "\t" + name + "\n";
	}
	
	@Override
	public Object getPrimaryKey(){
		return studentNumber;
	}
	
	public String toString(){
		return name;
	}

}
